<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提取超链接</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f6f7f9;
        }
        h1 {
            margin-top: 30px;
            text-align: center;
            color: #333;
        }
        textarea {
            width: 80%;
            max-width: 600px;
            margin: 20px auto;
            display: block;
            padding: 10px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 5px;
            resize: none;
        }
        button {
            display: block;
            margin: 0 auto;
            padding: 10px 20px;
            font-size: 16px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        ul {
            list-style-type: none;
            padding: 0;
            margin: 20px auto;
            max-width: 600px;
        }
        li {
            margin-bottom: 10px;
            background-color: #fff;
            padding: 10px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        a {
            color: #007bff;
            text-decoration: none;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <h1>提取超链接</h1>
    <textarea id="textInput" placeholder="在这里粘贴你的文本"></textarea>
    <button onclick="extractLinks()">提取链接</button>
    <ul id="linkList"></ul>

    <script>
        function extractLinks() {
            var text = document.getElementById('textInput').value;
            var linkList = document.getElementById('linkList');
            linkList.innerHTML = ''; // 清空之前的链接

            // 使用正则表达式提取链接
            var regex = /(https?:\/\/[^\s]+)/g;
            var matches = text.match(regex);

            if (matches) {
                matches.forEach(function(match) {
                    var li = document.createElement('li');
                    var a = document.createElement('a');
                    a.href = match;
                    a.textContent = match;
                    li.appendChild(a);
                    linkList.appendChild(li);
                });
            } else {
                var li = document.createElement('li');
                li.textContent = "未找到链接。";
                linkList.appendChild(li);
            }
        }
    </script>
</body>
</html>